package com.fs.controller.vo.device;

import com.fs.service.bo.device.BoSwitchWithState;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Data
public class VoSwitchState {
    private Integer Id;
    private String name;
    private String onLine;
    private String open;
    private String lastOnlineTime;

    public VoSwitchState(BoSwitchWithState bs){
        Id=bs.getSwitchId();
        name=bs.getName();
        onLine = bs.isOnline() ? "在线" : "掉线";
        open = bs.isOpen() ? "开闸" : "合闸";
        lastOnlineTime=bs.getLastOnlineTime();
    }

    public VoSwitchState(Integer Id, String name) {
        DateTimeFormatter formatter=  DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        this.Id=Id;
        this.name=name;
        this.onLine="在线";
        this.open="合闸";
        this.lastOnlineTime= LocalDateTime.now().minusMinutes(30).format(formatter);
    }
}
